/*
*	create by  jack ,20210705
*	
*	描述  
*		  该文件提供了一套线程调用的接口，屏蔽具体实现细节,以达到应用程序可以在不同的平台上联合调试。
*   修改记录：[内容][作者][时间]
*	
*/
#ifndef _SANJI_LIST_H_
#define _SANJI_LIST_H_

#include "define_comm.h"


#ifdef __cplusplus
extern "C"{
#endif


struct list{
	struct list *prev;
	struct list *next;
};

struct  list_iter{
	struct list	*i_list;
	struct list	*i_cur;
};

sj_void list_init(struct list *list);

sj_void list_add_tail(struct list *n, struct list *k);

sj_void list_add_head(struct list *n, struct list *k);


sj_void list_iter_init(struct list *k, struct list_iter *iter);

struct list *list_iter_next(struct list_iter *iter);

struct list *list_iter_prev(struct list_iter *iter);

sj_void list_iter_exit(struct list_iter *iter);

sj_bool list_iter_is_head(struct list_iter *iter);


#define LIST_INIT(name) struct list name={ &(name), &(name) }
	
#define LIST_ITER_INIT(name,k) struct list_iter name={ k,NULL }


#define container_of(ptr, type, member) \
    (type *)((char *)(ptr) - (char *) &((type *)0)->member)

#ifdef __cplusplus
}
#endif

#endif
